package mhe.mgt.service;

import mhe.mgt.model.*;

public class SystemServiceImpl extends GeneralServiceImpl<MchSystem> implements SystemService {

	@Override
	public Class<MchSystem> getEntityClass() {
		return MchSystem.class;
	}
	
	@Override
	public void delete(MchSystem entity) {
		// delete all machine parts of this system
		String hql = "delete from MCHMACHINEPART where machine_Id in (select id from MCHMACHINE where system_Id=:param0)"; //$NON-NLS-1$
		executeSQLQuery(hql, new Object[]{entity.getId()});
		// delete all machine of this system
		hql = "delete from MCHMACHINE where system_Id=:param0"; //$NON-NLS-1$
		executeSQLQuery(hql, new Object[]{entity.getId()});
		super.delete(entity);
	}
}
